home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / actlib11.zip / TVTOOLS.ZIP / INPUT.H < prev    next >
C/C++ Source or Header  |  1993-02-26  |  11KB  |  438 lines

  1. /*  Copyright (C) 1993   Marc Stern  (internet: stern@mble.philips.be)  */
  2.  
  3. class TStreamable;
  4. #include <values.h>
  5. #include "strings.h"
  6.  
  7.  
  8. #if defined(Uses_TInputKey) && ! defined(__TInputKey)
  9. #define __TInputKey
  10. // Same as TInputLine, except invalid if empty
  11.  
  12. class TInputKey : public TInputLine
  13. {
  14.  
  15. public:
  16.  
  17.     TInputKey( const TRect&, int len );
  18.     TInputKey( int x, int y, int len );
  19.     virtual Boolean valid( ushort );
  20.  
  21. protected:
  22.  
  23.     TInputKey( StreamableInit ) : TInputLine( streamableInit ) {};
  24.  
  25. private:
  26.  
  27.     virtual const char *streamableName() const
  28.         { return name; }
  29.  
  30. public:
  31.  
  32.     static const char * const name;
  33.     static TStreamable *build();
  34.  
  35. };
  36.  
  37.  
  38. inline ipstream& operator >> ( ipstream& is, TInputKey& cl )
  39.     { return is >> (TStreamable&)cl; }
  40. inline ipstream& operator >> ( ipstream& is, TInputKey*& cl )
  41.     { return is >> (void *&)cl; }
  42. inline opstream& operator << ( opstream& os, TInputKey& cl )
  43.     { return os << (TStreamable&)cl; }
  44. inline opstream& operator << ( opstream& os, TInputKey* cl )
  45.     { return os << (TStreamable *)cl; }
  46.  
  47. #endif // Uses_TInputKey
  48.  
  49.  
  50.  
  51. #if defined(Uses_TInputPasswd) && ! defined(__TInputPasswd)
  52. #define __TInputPasswd
  53. // Same as TInputLine, but display only '*'
  54.  
  55. class TInputPasswd : public TInputLine
  56. {
  57.  
  58. public:
  59.  
  60.     TInputPasswd( const TRect&, int len );
  61.     TInputPasswd( int x, int y, int len );
  62.     virtual void draw( void );
  63.  
  64. protected:
  65.  
  66.     TInputPasswd( StreamableInit ) : TInputLine( streamableInit ) {};
  67.  
  68. private:
  69.  
  70.     virtual const char *streamableName() const
  71.         { return name; }
  72.  
  73. public:
  74.  
  75.     static const char * const name;
  76.     static TStreamable *build();
  77.  
  78. };
  79.  
  80.  
  81. inline ipstream& operator >> ( ipstream& is, TInputPasswd& cl )
  82.     { return is >> (TStreamable&)cl; }
  83. inline ipstream& operator >> ( ipstream& is, TInputPasswd*& cl )
  84.     { return is >> (void *&)cl; }
  85. inline opstream& operator << ( opstream& os, TInputPasswd& cl )
  86.     { return os << (TStreamable&)cl; }
  87. inline opstream& operator << ( opstream& os, TInputPasswd* cl )
  88.     { return os << (TStreamable *)cl; }
  89.  
  90.  
  91. ushort inputPasswdBoxRect( const TRect &bounds,
  92.                            const char *Title,
  93.                            const char *aLabel,
  94.                            char *s,
  95.                            uchar limit );
  96.  
  97.  
  98. ushort inputPasswdBox( const char *Title, const char *aLabel, char *s, uchar limit );
  99.  
  100.  
  101. #endif // Uses_TInputPasswd
  102.  
  103.  
  104.  
  105. #if defined(Uses_TInputRegExp) && ! defined(__TInputRegExp)
  106. #define __TInputRegExp
  107. // Accepts only regular expression-matching input
  108.  
  109. class TInputRegExp: public TInputLine
  110. {
  111.  
  112. public:
  113.  
  114. #pragma warn -bei
  115.     TInputRegExp( const TRect&, int , const char * = 0, const char * = 0, casetype = 0 );
  116.     TInputRegExp( int x, int y, int , const char * = 0, const char * = 0, casetype = 0 );
  117.     ~TInputRegExp();
  118.     virtual void setState( ushort, Boolean );
  119.     virtual void handleEvent( TEvent& );
  120.     virtual Boolean valid( ushort );
  121.  
  122. protected:
  123.  
  124.     TInputRegExp( StreamableInit ) : TInputLine( streamableInit ) {};
  125.  
  126. private:
  127.  
  128.     char *set, *regexp;
  129.     casetype newcase;
  130.  
  131.     virtual const char *streamableName() const
  132.         { return name; }
  133.  
  134. public:
  135.  
  136.     static const char * const name;
  137.     static TStreamable *build();
  138.     static char *invMsg;
  139. };
  140.  
  141.  
  142. inline ipstream& operator >> ( ipstream& is, TInputRegExp& cl )
  143.     { return is >> (TStreamable&)cl; }
  144. inline ipstream& operator >> ( ipstream& is, TInputRegExp*& cl )
  145.     { return is >> (void *&)cl; }
  146. inline opstream& operator << ( opstream& os, TInputRegExp& cl )
  147.     { return os << (TStreamable&)cl; }
  148. inline opstream& operator << ( opstream& os, TInputRegExp* cl )
  149.     { return os << (TStreamable *)cl; }
  150.  
  151. #endif //  Uses_TInputRegExp
  152.  
  153.  
  154. #if defined(Uses_TInputInt) && ! defined(__TInputInt)
  155. #define __TInputInt
  156. // Accepts only valid numeric input (int) between Min and Max
  157.  
  158. class TInputInt : public TInputRegExp
  159. {
  160.  
  161. public:
  162.  
  163.     TInputInt( const TRect&, int len = 7, int min = -MAXINT, int max = MAXINT );
  164.     TInputInt( int x, int y, int len = 7, int min = -MAXINT, int max = MAXINT );
  165.     virtual ushort dataSize();
  166.     virtual void getData( void *);
  167.     virtual void setData( void *);
  168.     virtual Boolean valid( ushort );
  169.     int min;
  170.     int max;
  171.  
  172. protected:
  173.  
  174.     TInputInt( StreamableInit ) : TInputRegExp( streamableInit ) {};
  175.     virtual void write( opstream& );
  176.     virtual void *read( ipstream& );
  177.  
  178. private:
  179.  
  180.     virtual const char *streamableName() const
  181.         { return name; }
  182.  
  183. public:
  184.  
  185.     static const char * const name;
  186.     static TStreamable *build();
  187.  
  188. };
  189.  
  190. inline ipstream& operator >> ( ipstream& is, TInputInt& cl )
  191.     { return is >> (TStreamable&)cl; }
  192. inline ipstream& operator >> ( ipstream& is, TInputInt*& cl )
  193.     { return is >> (void *&)cl; }
  194. inline opstream& operator << ( opstream& os, TInputInt& cl )
  195.     { return os << (TStreamable&)cl; }
  196. inline opstream& operator << ( opstream& os, TInputInt* cl )
  197.     { return os << (TStreamable *)cl; }
  198.  
  199. #endif // Uses_TInputInt
  200.  
  201.  
  202.  
  203.  
  204.  
  205. #if defined(Uses_TInputLong) && ! defined(__TInputLong)
  206. #define __TInputLong
  207. // Accepts only valid numeric input (long) between Min and Max
  208.  
  209. class TInputLong : public TInputRegExp
  210. {
  211.  
  212. public:
  213.  
  214.     TInputLong( const TRect&, int len = 12, long min = -MAXLONG, long max = MAXLONG );
  215.     TInputLong( int x, int y, int len = 12, long min = -MAXLONG, long max = MAXLONG );
  216.     virtual ushort dataSize();
  217.     virtual void getData( void *);
  218.     virtual void setData( void *);
  219.     virtual Boolean valid( ushort );
  220.     long min;
  221.     long max;
  222.  
  223. protected:
  224.  
  225.     TInputLong( StreamableInit ) : TInputRegExp( streamableInit ) {};
  226.     virtual void write( opstream& );
  227.     virtual void *read( ipstream& );
  228.  
  229. private:
  230.  
  231.     virtual const char *streamableName() const
  232.         { return name; }
  233.  
  234. public:
  235.  
  236.     static const char * const name;
  237.     static TStreamable *build();
  238.  
  239. };
  240.  
  241. inline ipstream& operator >> ( ipstream& is, TInputLong& cl )
  242.     { return is >> (TStreamable&)cl; }
  243. inline ipstream& operator >> ( ipstream& is, TInputLong*& cl )
  244.     { return is >> (void *&)cl; }
  245. inline opstream& operator << ( opstream& os, TInputLong& cl )
  246.     { return os << (TStreamable&)cl; }
  247. inline opstream& operator << ( opstream& os, TInputLong* cl )
  248.     { return os << (TStreamable *)cl; }
  249.  
  250. #endif // Uses_TInputLong
  251.  
  252.  
  253.  
  254.  
  255.  
  256. #if defined(Uses_TInputDouble) && ! defined(__TInputDouble)
  257. #define __TInputDouble
  258. // Accepts only valid numeric input between Min and Max
  259.  
  260. class TInputDouble : public TInputRegExp
  261. {
  262.  
  263. public:
  264.  
  265.     TInputDouble( const TRect&, int len = 15, double min = -MAXDOUBLE, double max = MAXDOUBLE );
  266.     TInputDouble( int x, int y, int len = 15, double min = -MAXDOUBLE, double max = MAXDOUBLE );
  267.     virtual ushort dataSize();
  268.     virtual void getData( void *);
  269.     virtual void setData( void *);
  270.     virtual Boolean valid( ushort );
  271.     double min;
  272.     double max;
  273.  
  274. protected:
  275.  
  276.     TInputDouble( StreamableInit ) : TInputRegExp( streamableInit ) {};
  277.     virtual void write( opstream& );
  278.     virtual void *read( ipstream& );
  279.  
  280. private:
  281.  
  282.     virtual const char *streamableName() const
  283.         { return name; }
  284.  
  285. public:
  286.  
  287.     static const char * const name;
  288.     static TStreamable *build();
  289.  
  290. };
  291.  
  292. inline ipstream& operator >> ( ipstream& is, TInputDouble& cl )
  293.     { return is >> (TStreamable&)cl; }
  294. inline ipstream& operator >> ( ipstream& is, TInputDouble*& cl )
  295.     { return is >> (void *&)cl; }
  296. inline opstream& operator << ( opstream& os, TInputDouble& cl )
  297.     { return os << (TStreamable&)cl; }
  298. inline opstream& operator << ( opstream& os, TInputDouble* cl )
  299.     { return os << (TStreamable *)cl; }
  300.  
  301. #endif //  Uses_TInputDouble
  302.  
  303.  
  304.  
  305. #if defined(Uses_TInputHexa) && ! defined(__TInputHexa)
  306. #define __TInputHexa
  307. // Accepts only valid hexadecimal string input
  308.  
  309. class TInputHexa : public TInputRegExp
  310. {
  311.  
  312. public:
  313.  
  314.     TInputHexa( const TRect&, int len );
  315.     TInputHexa( int x, int y , int len );
  316.  
  317. protected:
  318.  
  319.     TInputHexa( StreamableInit ) : TInputRegExp( streamableInit ) {};
  320.  
  321. private:
  322.  
  323.     virtual const char *streamableName() const
  324.         { return name; }
  325.  
  326. public:
  327.  
  328.     static const char * const name;
  329.     static TStreamable *build();
  330.  
  331. };
  332.  
  333. inline ipstream& operator >> ( ipstream& is, TInputHexa& cl )
  334.     { return is >> (TStreamable&)cl; }
  335. inline ipstream& operator >> ( ipstream& is, TInputHexa*& cl )
  336.     { return is >> (void *&)cl; }
  337. inline opstream& operator << ( opstream& os, TInputHexa& cl )
  338.     { return os << (TStreamable&)cl; }
  339. inline opstream& operator << ( opstream& os, TInputHexa* cl )
  340.     { return os << (TStreamable *)cl; }
  341.  
  342. #endif // Uses_TInputHexa
  343.  
  344.  
  345.  
  346.  
  347.  
  348. #if defined(Uses_TInputDate) && ! defined(__TInputDate)
  349. #define __TInputDate
  350. // Accepts only valid date input
  351.  
  352. class TInputDate: public TInputRegExp
  353. {
  354.  
  355. public:
  356.  
  357.     TInputDate( const TRect& );
  358.     TInputDate( int x, int y );
  359.     virtual Boolean valid( ushort );
  360.  
  361. public:
  362.  
  363.     static const char * const name;
  364.  
  365. };
  366. #endif //  Uses_TInputDate
  367.  
  368.  
  369. #if defined(Uses_TInputCalcul) && ! defined(__TInputCalcul)
  370. #define __TInputCalcul
  371.  
  372. // Accepts a calculation string
  373.  
  374. class TInputCalcul : public TInputRegExp
  375. {
  376.  
  377. public:
  378.  
  379.     TInputCalcul( const TRect&, int len );
  380.     TInputCalcul( int x, int y, int len );
  381.     virtual Boolean valid( ushort );
  382.  
  383. protected:
  384.  
  385.     TInputCalcul( StreamableInit ) : TInputRegExp( streamableInit ) {};
  386.  
  387. private:
  388.  
  389.     virtual const char *streamableName() const
  390.         { return name; }
  391.  
  392. public:
  393.  
  394.     static const char * const name;
  395.     static TStreamable *build();
  396.  
  397. };
  398.  
  399.  
  400. inline ipstream& operator >> ( ipstream& is, TInputCalcul& cl )
  401.     { return is >> (TStreamable&)cl; }
  402. inline ipstream& operator >> ( ipstream& is, TInputCalcul*& cl )
  403.     { return is >> (void *&)cl; }
  404. inline opstream& operator << ( opstream& os, TInputCalcul& cl )
  405.     { return os << (TStreamable&)cl; }
  406. inline opstream& operator << ( opstream& os, TInputCalcul* cl )
  407.     { return os << (TStreamable *)cl; }
  408.  
  409. #endif // Uses_TInputCalcul
  410.  
  411.  
  412. #if defined(Uses_TStaticInputLine) && ! defined(__TStaticInputLine)
  413. #define __TStaticInputLine
  414.  
  415. // Accepts a static string
  416.  
  417. class TStaticInputLine : public TInputRegExp
  418. {
  419. protected:
  420.            TGenCollection *list;
  421.  
  422. public:
  423.            TStaticInputLine( const TRect&, int, TGenCollection *aList );
  424.            TStaticInputLine( int, int, int, TGenCollection *aList );
  425.  
  426. //           virtual TPalette& getPalette() const;
  427.            virtual void setData( void *rec );
  428.            virtual void handleEvent( TEvent& event );
  429.            virtual Boolean valid( ushort command );
  430.            virtual void newList( TGenCollection *aList );
  431.  
  432. public:
  433.            static const char * const near name;
  434.            char  testChar[255];
  435. };
  436.  
  437. #endif
  438.